<template>
  <button @click="changeCount()">count:{{ count }}</button>
  <button @click="changeValue()">count_2:{{ count_2 }}</button>
</template>
<script lang="ts" setup>
import { ref, watchEffect } from "vue";

//watchEffect 自动分析需要监听的依赖
const count = ref(0);

const count_2 = ref(1);

function changeCount() {
  count.value++;
}

function changeValue() {
  count_2.value++;
}

watchEffect(() => {
  if (count.value > 2 && count_2.value > 2) {
    console.log("xxx");
  }
});
</script>
<style scoped></style>
